#define _CRT_SECURE_NO_WARNINGS
#include"ListNode.h"
LN* Init() {
	LN* x = (LN*)malloc(sizeof(LN));
	x->a = 0;
	x->b = x;
	return x;
}
void ListHeader(LN* phead, x a) {
	LN* new = (LN*)malloc(sizeof(LN));
	new->a = a;
	new->b = NULL;
	LN* p = phead->b;
	phead->b = new;
	new->b = p;
}
void ListTailPlugging(LN* phead, x a) {
	LN* new = (LN*)malloc(sizeof(LN));
	new->a = a;
	new->b = NULL;
	LN* d = phead->b;
	if (d == phead) {
		phead->b = new;
		new->b = phead;
	}
	while (d != phead) {
		
		if (d->b == phead) {
				d->b = new;
				new->b = phead;
		}
		d = d->b;
	}
}
void y(LN* x, LN* y,LN* z) {
	LN* new = x->b;
	while (new != x) {
		if (new->a < 0) {
			ListHeader(y, new->a);
			new = new->b;
		}
		else if (new->a > 0) {
			ListTailPlugging(z, new->a);
			new = new->b;
		}
	}
}
void print(LN* x) {
	LN* new = x->b;
	while (new != x) {
		printf("%d ", new->a);
		new = new->b;
	}
	printf("\n");
}
void Destroy(LN* phead) {
	free(phead->b);
	phead->b = NULL;
	free(phead);
	phead = NULL;
}